1 using UnityEngine;
2 using
System.Collections;
3
4 public
class CarDriveRightSideScript : MonoBehaviour {
5
6     
private GameObject startingPoint;
7     
private GameObject endingPoint;
8
9     IronManBehaviorScript behaviorScript;
10
11     
public float speed = 23.0f;
12
13     
// Use this for initialization
14     
void Start () {
15         startingPoint = GameObject.Find (
"starting-point");
16         endingPoint = GameObject.Find (
"ending-point");
17         GameObject player = GameObject.FindGameObjectWithTag (
"Player");
18         behaviorScript = player.GetComponent<IronManBehaviorScript> ();
19     
20     }
21     
22     
// Update is called once per frame
23     
void Update () {
24         
if (behaviorScript.gameOver == true) {
25             speed =
0;
26         }
27         
28         
this.transform.position = new Vector3 (this.transform.position.x, this.transform.position.y, this.transform.position.z + speed * Time.deltaTime);
29         
if (this.transform.position.z > endingPoint.transform.position.z) {
30             
this.transform.position = new Vector3 (this.transform.position.x, this.transform.position.y, startingPoint.transform.position.z);
31         }
32     
33     }
34 }


Gõ tìm kiếm nhanh...